/*
 * Copyright (c) 2016-2017 fulihui.com All right reserved
 * Project: integral-business-parent
 * File name: FirstSignInIntegralBusinessHandler.java
 */

package com.fulihui.integralbusiness.handler;

import com.fulihui.integral.core.enums.ISChannelType;
import com.fulihui.integral.core.request.RewardPointsReq;
import com.fulihui.integral.core.result.ISUserBehaviorResult;
import com.fulihui.integralbusiness.constants.IntegralBusinessFlags;
import org.near.servicesupport.util.ServiceResultUtil;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author Willard.Hu on 2017/4/27 0027.
 */
@Component("firstSignInIntegralBusinessHandler")
public class FirstSignInIntegralBusinessHandler extends AbstractIntegralBusinessHandler {

    @Override
    public void handle(Map<String, Object> msg) {
        RewardPointsReq req = new RewardPointsReq();
        req.setUserId((String) msg.get("userId"));
        req.setChannel(ISChannelType.NEW_REGISTER.getCode());
        ISUserBehaviorResult res = userBehaviorService.rewardPoints(req);
        ServiceResultUtil.checkResult(res);
    }

    @Override
    IntegralBusinessFlags getFlag() {
        return IntegralBusinessFlags.FIRST_SIGNIN;
    }
}
